#!/usr/bin/python
# -*- coding:utf-8 -*-
#仿Java的ArrayList
#@author: wklken@yeah.net

#第一版，非继承，需加工  不考虑异常

class ArrayList:
    def add(self, o):
        self.data.append(o)
    def add_in(self, index, o):
        self.data.insert(index, 0)
    def addAll(self, l):
        self.data.extend(l)
    def addAll_in(self, index , l):
        self.data = self.data[:index] + l + self.data[index:]
    def clear(self):
        self.data = []
    def contains(self, v):
        return v in self.data
    def get(self, index):
        return self.data[index]
    def indexOf(self, v):
        return self.data.index(v)
    def isEmpty(self):
        return len(self.data) == 0
    def lastIndexOf(self, v):
        for i in range(len(self.data)-1,-1, -1):
            if self.data[i] == v:
                return i 
        return  -1
    def remove_i(self, index):
        del self.data[index]
    def remove(self, o):
        self.data.remove(o)
    def removeRange(self, from_i, to_i):
        del self.data[from_i:to_i]
    def set(self, index, value):
        self.data[index] = vaule
    def toArray(self):
        return self.data

            